#include <REGX51.H>
#include <intrins.h>
unsigned char code num1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //共阴极
unsigned char code num2[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //共阳极


void Delay100ms(void)	//@12.000MHz
{
	unsigned char data i, j, k;

	_nop_();
	_nop_();
	i = 5;
	j = 144;
	k = 71;
	do
	{
		do
		{
			while (--k);
		} while (--j);
	} while (--i);
}

void Delay50ms(void)	//@12.000MHz
{
	unsigned char data i, j, k;

	_nop_();
	_nop_();
	i = 3;
	j = 72;
	k = 161;
	do
	{
		do
		{
			while (--k);
		} while (--j);
	} while (--i);
}


void Delay1ms(void)	//@12.000MHz
{
	unsigned char data i, j;

	i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
}

void Delay50us(void)	//@12.000MHz
{
	unsigned char data i;

	_nop_();
	_nop_();
	i = 147;
	while (--i);
}



void static_tab(int x,int y)
{
	switch(x)
	{
		case 1:P2=0x01;break;
		case 2:P2=0x02;break;
		case 3:P2=0x04;break;
		case 4:P2=0x08;break;
	}
	P0=num2[y];
	Delay50us();
}

void main()
{
	while(1)
		{
			static_tab(2,1);
			static_tab(3,2);
			static_tab(4,4);

		}
	
}
